package com.intelligentclass.repositories;

import com.intelligentclass.entity.Teacher;
import com.intelligentclass.entity.Teaching;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface TeachingRespository extends JpaRepository<Teaching, Integer> {

    @Query("SELECT t FROM Teaching t WHERE t.cid = :cid")
    public List<Teacher> findAllTeacher(@Param("cid") int cid);

    @Query("SELECT c.cname FROM Course c WHERE c.cno in (SELECT t.cno FROM Teaching t WHERE t.cid = :cid)")
    public String getCnameByCid(int cid);
}
